package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.response.FoodMenu;
import com.pj.wisdomlogistics.mvp.contract.MenuEditorContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.MenuEditorModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;

import java.util.List;


public class MenuEditorPresenter extends ActivityPresenter<MenuEditorModel, MenuEditorContract.View> implements MenuEditorContract.Presenter {
    public static final String TAG = "MenuEditorPresenter";

    @Override
    public void findNoodleFood(String userID) {
        addSubscription(getModel().findNoodleFood(userID), new FilterSubscriber<List<FoodMenu>>() {
            @Override
            public void onNext(List<FoodMenu> menuList) {
                getView().onFindSuccess(menuList);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

        });
    }

    @Override
    public void findCookFood() {
        addSubscription(getModel().findCookFood(), new FilterSubscriber<List<FoodMenu>>() {
            @Override
            public void onNext(List<FoodMenu> menuList) {
                getView().onFindSuccess(menuList);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }


        });
    }

    @Override
    public void findCookFood2(String userID) {
        addSubscription(getModel().findCookFood2(userID), new FilterSubscriber<List<FoodMenu>>() {
            @Override
            public void onNext(List<FoodMenu> menuList) {
                getView().onFindSuccess(menuList);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }


        });
    }





    @Override
    public void modifyNoodleMenu(String foodJson , String userID) {
        addSubscription(getModel().modifyNoodleMenu(foodJson , userID), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object o) {
                getView().onSendSuccess();
            }
        });
    }

    @Override
    public void modifyMenu(String foodJson) {
        addSubscription(getModel().modifyMenu(foodJson), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object o) {
                getView().onSendSuccess();
            }
        });
    }
}
